package com.rjwh.dingdong.client.network;

import android.util.SparseArray;

import com.aishua.lib.task.AsResult;
import com.aishua.lib.utils.AsStrUtils;
import com.alibaba.fastjson.JSON;
import com.rjwh.dingdong.client.bean.jsonbean.ResAddBabyBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResAddBabyCheckBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResAppStartUpBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResBaseBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGameCompareVersion;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetAge;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetBookIslandGameBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetDigestTopicListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetDingDongMathGameBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetDrawBookCatalogBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetDrawBookDetailBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetDrawBookMainPage;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetHomeWorkFansFollowListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetHomeWorkListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetLastMathGameFootStepBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMainPageBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMathBookCommentListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMathBookDetailBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMathGameMainPage;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMathGameRecord;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMessageListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetModularList;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMyMainPageBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMyScorePageBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetMyScoreRecordBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetPersonalCenterBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetPictureBookCommentListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetPictureBookMainPageBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetPostBasicDataBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetRadioAblumListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetRadioAlbumProgramBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetRadioAnchorHomePageBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetRadioAnchorListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetRadioPageBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetRankingListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetTopicFavoriteBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetTopicList;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetTopicNoticeListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResGetUserOuterAccountListBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResHomeworkAssignBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResPublishTopicBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResSysLogin;
import com.rjwh.dingdong.client.bean.jsonbean.ResUserLoginBean;
import com.rjwh.dingdong.client.bean.jsonbean.ResUserOuterSysLoginBean;
import com.rjwh.dingdong.client.constant.LocalConstant;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.util.LogUtil;

import org.ksoap2.serialization.SoapObject;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NetConnection {
    private static final String TAG = "NetConnection";
    public final static int HTTP_CONNECT_TIME_OUT = 1000 * 15;

    private static NetConnection mNetConstant;

    public static NetConnection getInstant() {
        if (mNetConstant == null) {
            mNetConstant = new NetConnection();
        }
        return mNetConstant;
    }

    private NetConnection() {
        array = new SparseArray<>();
        array.put(NetConstant.USERLOGIN, "userLogin");

        array.put(NetConstant.REGISTERDEVICETOKEN, "registerDeviceToken");
        //社区获取模块
        array.put(NetConstant.COMMUNITY_GETMODULARLIST, "community_getModularList");
        //社区发布帖子
        array.put(NetConstant.COMMUNITY_PUBLISHTOPIC, "community_publishTopic");
        //社区帖子列表
        array.put(NetConstant.COMMUNITY_GETTOPICLIST, "community_getTopicList");
        //社区帖子回复
        array.put(NetConstant.COMMUNITY_PUBLISHREPLY, "community_publishReply");
        //社区帖子收藏
        array.put(NetConstant.COMMUNITY_ADDTOFAVORITEGOOD, "community_addToFavoriteGood");
        //社区帖子点赞收藏等状态
        array.put(NetConstant.COMMUNITY_GETPOSTBASICDATA, "community_getPostBasicData");
        //社区消息
        array.put(NetConstant.COMMUNITY_GETNOTICELISTBYUSERID, "community_getNoticeListByUserid");
        //绘本管
        array.put(NetConstant.GETDRAWBOOKCATALOG, "getDrawBookCatalog");
        //绘本主页
        array.put(NetConstant.GETDRAWBOOKMAINPAGE, "getDrawBookMainPage");
        //获取绘本详情
        array.put(NetConstant.GETDRAWBOOKDETAIL, "getDrawBookDetail");
        //获取宝宝年龄
        array.put(NetConstant.GETAGE, "getAge");
        //获取验证码
        array.put(NetConstant.TYPE_SMS_CODE, "requestVerifyCode");
        //验证码校验
        array.put(NetConstant.TYPE_CONFIRM_SMS_CODE, "checkVerifyCode");
        //找回密码
        array.put(NetConstant.TYPE_MODIFY_WORD, "ResetPassword");
        //用户注册
        array.put(NetConstant.USERREGISTER, "UserRegister");
        //数学游戏主页
        array.put(NetConstant.GETMATHGAMEMAINPAGE, "getMathGameMainPage");
        //游戏记录
        array.put(NetConstant.GETMATHGAMERECORD, "getMathGameRecord");
        //用户登陆(新)
        array.put(NetConstant.SYSLOGIN, "syslogin");
        //游戏版本比较
        array.put(NetConstant.COMPAREVERSION, "compareVersion");
        //意见反馈
        array.put(NetConstant.LEAVEMESSAGE, "leaveMessage");
        //添加宝宝
        array.put(NetConstant.ADDBABY, "addBaby");
        //添加宝宝时的验证
        array.put(NetConstant.ADDBABYCHECK, "addBabyCheck");
        //删除宝宝
        array.put(NetConstant.DELBABY, "delBaby");
        //切换宝宝帐号
        array.put(NetConstant.TOGGLEBABYACCOUNT, "toggleBabyAccount");
        //修改宝宝资料
        array.put(NetConstant.SAVEBABYDATA, "saveBabyData");
        //修改用户资料
        array.put(NetConstant.SAVEPARENTDATA, "saveParentData");

        //帖子收藏列表
        array.put(NetConstant.GETTOPICFAVORITE, "getTopicFavorite");

        //我的社区主页
        array.put(NetConstant.COMMUNITY_GETMYMAINPAGE, "community_getMyMainPage");

        //绘本主页(新)
        array.put(NetConstant.GETPICTUREBOOKMAINPAGE, "getPictureBookMainPage");

        //精华帖子列表
        array.put(NetConstant.COMMUNITY_GETDIGESTTOPICLIST, "community_getDigestTopicList");

        //添加绘本评论
        array.put(NetConstant.POSTDRAWBOOKCOMMENT, "postDrawBookComment");
        //绘本评论列表
        array.put(NetConstant.GETPICTUREBOOKCOMMENTLIST, "getPictureBookCommentList");

        //取教材所有游戏
        array.put(NetConstant.GETBOOKISLANDGAME, "getBookIslandGame");
        //添加游戏评论
        array.put(NetConstant.POSTMATHBOOKCOMMENT, "postMathBookComment");
        //游戏评论列表
        array.put(NetConstant.GETMATHBOOKCOMMENTLIST, "getMathBookCommentList");

        //获取游戏主页
        array.put(NetConstant.GETDINGDONGMATHGAME, "getDingDongMathGame");
        //获取游戏详情(岛)
        array.put(NetConstant.GETMATHBOOKDETAIL, "getMathBookDetail");
        //游戏足迹
        array.put(NetConstant.GETLASTMATHGAMEFOOTSTEP, "getLastMathGameFootStep");


        //1.3版本接口
        //我的积分
        array.put(NetConstant.GETMYSCOREPAGE, "getMyScorePage");
        //积分明细
        array.put(NetConstant.GETMYSCORERECORD, "getMyScoreRecord");
        //个人中心
        array.put(NetConstant.GETPERSONALCENTER, "getPersonalCenter");

        //第三方登录
        array.put(NetConstant.USEROUTERSYSLOGIN, "UserOuterSysLogin");
        //第三方登录用户绑定手机
        array.put(NetConstant.USEROUTERSYSBIND, "UserOuterSysBind");
        //手机号快捷登录
        array.put(NetConstant.SYSSMSCODELOGIN, "sysSmsCodelogin");

        //第三方账号绑定列表
        array.put(NetConstant.GETUSEROUTERACCOUNTLIST, "getUserOuterAccountList");
        //第三方帐号解绑
        array.put(NetConstant.USEROUTERSYSUNBIND, "UserOuterSysUnBind");
        //修改密码
        array.put(NetConstant.UPDATEPWD, "updatePwd");
        //第三方帐号绑定
        array.put(NetConstant.USERBINDOUTERACCOUNT, "UserBindOuterAccount");

        //1.4版本接口
        // 主页
        array.put(NetConstant.GETMAINPAGE, "getMainPage");
        //听听主页
        array.put(NetConstant.GETRADIOPAGE, "getRadioPage");
        //节目列表页面
        array.put(NetConstant.GETRADIOALBUMPROGRAMLIST, "getRadioAlbumProgramList");

        //获取游戏列表(带版本号)
        array.put(NetConstant.GETBOOKISLANDGAMEBYVERSION, "getBookIslandGameByVersion");
        //获取游戏足迹(带版本号)
        array.put(NetConstant.GETLASTMATHGAMEFOOTSTEPBYVERSION, "getLastMathGameFootStepByVersion");

        //绑定推送
        array.put(NetConstant.PUSHBINDING, "PushBinding");
        //获取专辑列表
        array.put(NetConstant.GETRADIOABLUMLIST, "getRadioAblumList");
        //获取主播列表
        array.put(NetConstant.GETRADIOLIST, "getRadioList");
        //获取主播主页
        array.put(NetConstant.GETRADIODATA, "getRadioData");
        //退出登录
        array.put(NetConstant.SYSLOGOUT, "syslogout");

        //绑定推送
        array.put(NetConstant.PUSHBINDINGFORAPPID, "PushBindingForAppId");

        //消息列表
        array.put(NetConstant.GETMESSAGELIST, "getMessageList");

        //家庭作业列表
        array.put(NetConstant.GETHOMEWORKLIST, "getHomeWorkList");
        //作业分享积分排行榜
        array.put(NetConstant.GETRANKINGLIST, "getRankingList");
        //作业分享我的粉丝
        array.put(NetConstant.GETHOMEWORKFANSFOLLOWLIST, "getHomeWorkFansFollowList");
        //我的粉丝--关注
        array.put(NetConstant.HOMEWORK_FOLLOW, "homework_Follow");
        //登记作业
        array.put(NetConstant.HOMEWORK_ASSIGN, "homework_Assign");

        //启动更新数据
        array.put(NetConstant.APPSTARTUP, "AppStartUp");
    }

    public AsResult getNetJsonData(int businessType, Map<String, String> params) {
        String jsonRes = executeWebServiceReq(businessType, params);
        return parsJosnData(businessType, jsonRes);
    }

    /**
     * 描述：请求参数中单一无嵌套
     *
     * @param businessType
     * @param jsonRes
     * @return AsResult
     */
    public AsResult parsJosnData(int businessType, String jsonRes) {
        AsResult mAsResult = new AsResult();
        try {
            LogUtil.d(TAG, "jsonRes: " + jsonRes);
            if (AsStrUtils.isEmpty(jsonRes)) {
                mAsResult.setResultCode(NetConstant.MSG_CONNECT_JSON_FAILED);
                return mAsResult;
            }

            switch (businessType) {
                case NetConstant.USERLOGIN:
                    ResUserLoginBean userLogin = JSON.parseObject(jsonRes, ResUserLoginBean.class);
                    mAsResult.setResultCode(Integer.valueOf(userLogin.getExeustate().getState()));
                    mAsResult.setResultMsg(userLogin.getExeustate().getMsg());
                    mAsResult.setObj(userLogin);
                    break;

                case NetConstant.REGISTERDEVICETOKEN:
                    ResBaseBean pushRegist = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(pushRegist.getExeustate().getState()));
                    mAsResult.setResultMsg(pushRegist.getExeustate().getMsg());
                    break;

                case NetConstant.COMMUNITY_GETMODULARLIST:
                    ResGetModularList getModularList = JSON.parseObject(jsonRes, ResGetModularList.class);
                    mAsResult.setResultCode(Integer.valueOf(getModularList.getExeustate().getState()));
                    mAsResult.setResultMsg(getModularList.getExeustate().getMsg());
                    mAsResult.setObj(getModularList);
                    break;
                case NetConstant.COMMUNITY_PUBLISHTOPIC:
                    ResPublishTopicBean publishTopic = JSON.parseObject(jsonRes, ResPublishTopicBean.class);
                    mAsResult.setResultCode(Integer.valueOf(publishTopic.getExeustate().getState()));
                    mAsResult.setResultMsg(publishTopic.getExeustate().getMsg());
                    mAsResult.setObj(publishTopic);
                    break;
                case NetConstant.COMMUNITY_GETTOPICLIST:
                    ResGetTopicList getTopicList = JSON.parseObject(jsonRes, ResGetTopicList.class);
                    mAsResult.setResultCode(Integer.valueOf(getTopicList.getExeustate().getState()));
                    mAsResult.setResultMsg(getTopicList.getExeustate().getMsg());
                    mAsResult.setObj(getTopicList);
                    break;
                case NetConstant.COMMUNITY_PUBLISHREPLY:
                    ResBaseBean publishReply = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(publishReply.getExeustate().getState()));
                    mAsResult.setResultMsg(publishReply.getExeustate().getMsg());
                    break;
                case NetConstant.COMMUNITY_ADDTOFAVORITEGOOD:
                    ResBaseBean addToFavoriteGood = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(addToFavoriteGood.getExeustate().getState()));
                    mAsResult.setResultMsg(addToFavoriteGood.getExeustate().getMsg());
                    break;
                case NetConstant.COMMUNITY_GETPOSTBASICDATA:
                    ResGetPostBasicDataBean getPostBasicData = JSON.parseObject(jsonRes, ResGetPostBasicDataBean.class);
                    mAsResult.setResultCode(Integer.valueOf(getPostBasicData.getExeustate().getState()));
                    mAsResult.setResultMsg(getPostBasicData.getExeustate().getMsg());
                    mAsResult.setObj(getPostBasicData);
                    break;
                case NetConstant.COMMUNITY_GETNOTICELISTBYUSERID:
                    ResGetTopicNoticeListBean getNoticeListByUserid = JSON.parseObject(jsonRes, ResGetTopicNoticeListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(getNoticeListByUserid.getExeustate().getState()));
                    mAsResult.setResultMsg(getNoticeListByUserid.getExeustate().getMsg());
                    mAsResult.setObj(getNoticeListByUserid);
                    break;
                case NetConstant.GETDRAWBOOKCATALOG:
                    ResGetDrawBookCatalogBean getDrawBookCatalogBean = JSON.parseObject(jsonRes, ResGetDrawBookCatalogBean.class);
                    mAsResult.setResultCode(Integer.valueOf(getDrawBookCatalogBean.getExeustate().getState()));
                    mAsResult.setResultMsg(getDrawBookCatalogBean.getExeustate().getMsg());
                    mAsResult.setObj(getDrawBookCatalogBean);
                    break;
                case NetConstant.GETDRAWBOOKMAINPAGE:
                    ResGetDrawBookMainPage resGetDrawBookMainPage = JSON.parseObject(jsonRes, ResGetDrawBookMainPage.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetDrawBookMainPage.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetDrawBookMainPage.getExeustate().getMsg());
                    mAsResult.setObj(resGetDrawBookMainPage);
                    break;
                case NetConstant.GETAGE:
                    ResGetAge resGetAge = JSON.parseObject(jsonRes, ResGetAge.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetAge.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetAge.getExeustate().getMsg());
                    mAsResult.setObj(resGetAge);
                    break;
                case NetConstant.TYPE_SMS_CODE:
                    ResBaseBean RequestVerifyCode = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(RequestVerifyCode.getExeustate().getState()));
                    mAsResult.setResultMsg(RequestVerifyCode.getExeustate().getMsg());
                    break;
                case NetConstant.TYPE_CONFIRM_SMS_CODE:
                    ResBaseBean CheckVerifyCode = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(CheckVerifyCode.getExeustate().getState()));
                    mAsResult.setResultMsg(CheckVerifyCode.getExeustate().getMsg());
                    break;
                case NetConstant.TYPE_MODIFY_WORD:
                    ResBaseBean ResetPassword = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(ResetPassword.getExeustate().getState()));
                    mAsResult.setResultMsg(ResetPassword.getExeustate().getMsg());
                    break;
                case NetConstant.USERREGISTER:
                    ResBaseBean UserRegister = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(UserRegister.getExeustate().getState()));
                    mAsResult.setResultMsg(UserRegister.getExeustate().getMsg());
                    break;
                case NetConstant.GETDRAWBOOKDETAIL:
                    ResGetDrawBookDetailBean resGetDrawBookDetailBean = JSON.parseObject(jsonRes, ResGetDrawBookDetailBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetDrawBookDetailBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetDrawBookDetailBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetDrawBookDetailBean);
                    break;
                case NetConstant.GETMATHGAMEMAINPAGE:
                    ResGetMathGameMainPage resGetMathGameMainPage = JSON.parseObject(jsonRes, ResGetMathGameMainPage.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMathGameMainPage.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMathGameMainPage.getExeustate().getMsg());
                    mAsResult.setObj(resGetMathGameMainPage);
                    break;
                case NetConstant.GETMATHGAMERECORD:
                    ResGetMathGameRecord resGetMathGameRecord = JSON.parseObject(jsonRes, ResGetMathGameRecord.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMathGameRecord.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMathGameRecord.getExeustate().getMsg());
                    mAsResult.setObj(resGetMathGameRecord);
                    break;
                case NetConstant.SYSLOGIN:
                    ResSysLogin resSysLogin = JSON.parseObject(jsonRes, ResSysLogin.class);
                    mAsResult.setResultCode(Integer.valueOf(resSysLogin.getExeustate().getState()));
                    mAsResult.setResultMsg(resSysLogin.getExeustate().getMsg());
                    mAsResult.setObj(resSysLogin);
                    break;

                case NetConstant.COMPAREVERSION:
                    ResGameCompareVersion resGameCompareVersion = JSON.parseObject(jsonRes, ResGameCompareVersion.class);
                    mAsResult.setResultCode(Integer.valueOf(resGameCompareVersion.getExeustate().getState()));
                    mAsResult.setResultMsg(resGameCompareVersion.getExeustate().getMsg());
                    mAsResult.setObj(resGameCompareVersion);
                    break;
                case NetConstant.LEAVEMESSAGE:
                    ResBaseBean leaveMessageBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(leaveMessageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(leaveMessageBean.getExeustate().getMsg());
                    break;
                case NetConstant.ADDBABY:
                    ResAddBabyBean addBabyBean = JSON.parseObject(jsonRes, ResAddBabyBean.class);
                    mAsResult.setResultCode(Integer.valueOf(addBabyBean.getExeustate().getState()));
                    mAsResult.setResultMsg(addBabyBean.getExeustate().getMsg());
                    mAsResult.setObj(addBabyBean);
                    break;
                case NetConstant.ADDBABYCHECK:
                    ResAddBabyCheckBean addBabyCheckBean = JSON.parseObject(jsonRes, ResAddBabyCheckBean.class);
                    mAsResult.setResultCode(Integer.valueOf(addBabyCheckBean.getExeustate().getState()));
                    mAsResult.setResultMsg(addBabyCheckBean.getExeustate().getMsg());
                    mAsResult.setObj(addBabyCheckBean);
                    break;
                case NetConstant.DELBABY:
                    ResBaseBean delBabyBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(delBabyBean.getExeustate().getState()));
                    mAsResult.setResultMsg(delBabyBean.getExeustate().getMsg());
                    break;
                case NetConstant.TOGGLEBABYACCOUNT:
                    ResBaseBean toggleBabyAccountBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(toggleBabyAccountBean.getExeustate().getState()));
                    mAsResult.setResultMsg(toggleBabyAccountBean.getExeustate().getMsg());
                    break;
                case NetConstant.SAVEBABYDATA:
                    ResBaseBean saveBabyDataBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(saveBabyDataBean.getExeustate().getState()));
                    mAsResult.setResultMsg(saveBabyDataBean.getExeustate().getMsg());
                    break;
                case NetConstant.SAVEPARENTDATA:
                    ResBaseBean saveParentDataBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(saveParentDataBean.getExeustate().getState()));
                    mAsResult.setResultMsg(saveParentDataBean.getExeustate().getMsg());
                    break;
                case NetConstant.GETTOPICFAVORITE:
                    ResGetTopicFavoriteBean resGetTopicFavoriteBean = JSON.parseObject(jsonRes, ResGetTopicFavoriteBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetTopicFavoriteBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetTopicFavoriteBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetTopicFavoriteBean);
                    break;
                case NetConstant.COMMUNITY_GETMYMAINPAGE:
                    ResGetMyMainPageBean getMyMainPageBean = JSON.parseObject(jsonRes, ResGetMyMainPageBean.class);
                    mAsResult.setResultCode(Integer.valueOf(getMyMainPageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(getMyMainPageBean.getExeustate().getMsg());
                    mAsResult.setObj(getMyMainPageBean);
                    break;
                case NetConstant.GETPICTUREBOOKMAINPAGE:
                    ResGetPictureBookMainPageBean resGetPictureBookMainPageBean = JSON.parseObject(jsonRes, ResGetPictureBookMainPageBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetPictureBookMainPageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetPictureBookMainPageBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetPictureBookMainPageBean);
                    break;
                case NetConstant.COMMUNITY_GETDIGESTTOPICLIST:
                    ResGetDigestTopicListBean getDigestTopicListBean = JSON.parseObject(jsonRes, ResGetDigestTopicListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(getDigestTopicListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(getDigestTopicListBean.getExeustate().getMsg());
                    mAsResult.setObj(getDigestTopicListBean);
                    break;
                case NetConstant.POSTDRAWBOOKCOMMENT:
                    ResBaseBean postDrawBookComment = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(postDrawBookComment.getExeustate().getState()));
                    mAsResult.setResultMsg(postDrawBookComment.getExeustate().getMsg());
                    break;
                case NetConstant.GETPICTUREBOOKCOMMENTLIST:
                    ResGetPictureBookCommentListBean getPictureBookCommentListBean = JSON.parseObject(jsonRes, ResGetPictureBookCommentListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(getPictureBookCommentListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(getPictureBookCommentListBean.getExeustate().getMsg());
                    mAsResult.setObj(getPictureBookCommentListBean);
                    break;
                case NetConstant.GETBOOKISLANDGAME:
                    ResGetBookIslandGameBean resGetBookIslandGameBean = JSON.parseObject(jsonRes, ResGetBookIslandGameBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetBookIslandGameBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetBookIslandGameBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetBookIslandGameBean);
                    break;
                case NetConstant.POSTMATHBOOKCOMMENT:
                    ResBaseBean postMathBookComment = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(postMathBookComment.getExeustate().getState()));
                    mAsResult.setResultMsg(postMathBookComment.getExeustate().getMsg());
                    break;
                case NetConstant.GETMATHBOOKCOMMENTLIST:
                    ResGetMathBookCommentListBean resGetMathBookCommentListBean = JSON.parseObject(jsonRes, ResGetMathBookCommentListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMathBookCommentListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMathBookCommentListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetMathBookCommentListBean);
                    break;
                case NetConstant.GETDINGDONGMATHGAME:
                    ResGetDingDongMathGameBean resGetDingDongMathGameBean = JSON.parseObject(jsonRes, ResGetDingDongMathGameBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetDingDongMathGameBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetDingDongMathGameBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetDingDongMathGameBean);
                    break;
                case NetConstant.GETLASTMATHGAMEFOOTSTEP:
                    ResGetLastMathGameFootStepBean resGetLastMathGameFootStepBean = JSON.parseObject(jsonRes, ResGetLastMathGameFootStepBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetLastMathGameFootStepBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetLastMathGameFootStepBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetLastMathGameFootStepBean);
                    break;
                case NetConstant.GETMATHBOOKDETAIL:
                    ResGetMathBookDetailBean resGetMathBookDetailBean = JSON.parseObject(jsonRes, ResGetMathBookDetailBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMathBookDetailBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMathBookDetailBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetMathBookDetailBean);
                    break;
                case NetConstant.GETMYSCOREPAGE:
                    ResGetMyScorePageBean resGetMyScorePageBean = JSON.parseObject(jsonRes, ResGetMyScorePageBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMyScorePageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMyScorePageBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetMyScorePageBean);
                    break;
                case NetConstant.GETMYSCORERECORD:
                    ResGetMyScoreRecordBean resGetMyScoreRecordBean = JSON.parseObject(jsonRes, ResGetMyScoreRecordBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMyScoreRecordBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMyScoreRecordBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetMyScoreRecordBean);
                    break;
                case NetConstant.GETPERSONALCENTER:
                    ResGetPersonalCenterBean resGetPersonalCenterBean = JSON.parseObject(jsonRes, ResGetPersonalCenterBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetPersonalCenterBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetPersonalCenterBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetPersonalCenterBean);
                    break;
                case NetConstant.USEROUTERSYSLOGIN:
                    ResUserOuterSysLoginBean resUserOuterSysLoginBean = JSON.parseObject(jsonRes, ResUserOuterSysLoginBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resUserOuterSysLoginBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resUserOuterSysLoginBean.getExeustate().getMsg());
                    mAsResult.setObj(resUserOuterSysLoginBean);
                    break;
                case NetConstant.USEROUTERSYSBIND:
                    ResUserOuterSysLoginBean resUserOuterSysBindBean = JSON.parseObject(jsonRes, ResUserOuterSysLoginBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resUserOuterSysBindBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resUserOuterSysBindBean.getExeustate().getMsg());
                    mAsResult.setObj(resUserOuterSysBindBean);
                    break;
                case NetConstant.SYSSMSCODELOGIN:
                    ResSysLogin sysSmsCodeloginBean = JSON.parseObject(jsonRes, ResSysLogin.class);
                    mAsResult.setResultCode(Integer.valueOf(sysSmsCodeloginBean.getExeustate().getState()));
                    mAsResult.setResultMsg(sysSmsCodeloginBean.getExeustate().getMsg());
                    mAsResult.setObj(sysSmsCodeloginBean);
                    break;
                case NetConstant.GETUSEROUTERACCOUNTLIST:
                    ResGetUserOuterAccountListBean resGetUserOuterAccountListBean = JSON.parseObject(jsonRes, ResGetUserOuterAccountListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetUserOuterAccountListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetUserOuterAccountListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetUserOuterAccountListBean);
                    break;
                case NetConstant.USEROUTERSYSUNBIND:
                    ResBaseBean UserOuterSysUnBindBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(UserOuterSysUnBindBean.getExeustate().getState()));
                    mAsResult.setResultMsg(UserOuterSysUnBindBean.getExeustate().getMsg());
                    break;
                case NetConstant.UPDATEPWD:
                    ResBaseBean updatePwdBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(updatePwdBean.getExeustate().getState()));
                    mAsResult.setResultMsg(updatePwdBean.getExeustate().getMsg());
                    break;
                case NetConstant.USERBINDOUTERACCOUNT:
                    ResBaseBean userBindOuterAccountBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(userBindOuterAccountBean.getExeustate().getState()));
                    mAsResult.setResultMsg(userBindOuterAccountBean.getExeustate().getMsg());
                    break;
                case NetConstant.GETMAINPAGE:
                    ResGetMainPageBean resGetMainPageBean = JSON.parseObject(jsonRes, ResGetMainPageBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMainPageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMainPageBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetMainPageBean);
                    break;
                case NetConstant.GETRADIOPAGE:
                    ResGetRadioPageBean resGetRadioPageBean = JSON.parseObject(jsonRes, ResGetRadioPageBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetRadioPageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetRadioPageBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetRadioPageBean);
                    break;
                case NetConstant.GETRADIOALBUMPROGRAMLIST:
                    ResGetRadioAlbumProgramBean resGetRadioAlbumProgramBean = JSON.parseObject(jsonRes, ResGetRadioAlbumProgramBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetRadioAlbumProgramBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetRadioAlbumProgramBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetRadioAlbumProgramBean);
                    break;
                case NetConstant.GETBOOKISLANDGAMEBYVERSION:
                    ResGetBookIslandGameBean resGetBookIslandGameByVersionBean = JSON.parseObject(jsonRes, ResGetBookIslandGameBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetBookIslandGameByVersionBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetBookIslandGameByVersionBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetBookIslandGameByVersionBean);
                    break;
                case NetConstant.GETLASTMATHGAMEFOOTSTEPBYVERSION:
                    ResGetLastMathGameFootStepBean resGetLastMathGameFootStepByVersionBean = JSON.parseObject(jsonRes, ResGetLastMathGameFootStepBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetLastMathGameFootStepByVersionBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetLastMathGameFootStepByVersionBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetLastMathGameFootStepByVersionBean);
                    break;
                case NetConstant.PUSHBINDING:
                    ResBaseBean pushBindingBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(pushBindingBean.getExeustate().getState()));
                    mAsResult.setResultMsg(pushBindingBean.getExeustate().getMsg());
                    break;
                case NetConstant.GETRADIOABLUMLIST:
                    ResGetRadioAblumListBean resGetRadioAblumListBean = JSON.parseObject(jsonRes, ResGetRadioAblumListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetRadioAblumListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetRadioAblumListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetRadioAblumListBean);
                    break;
                case NetConstant.GETRADIOLIST:
                    ResGetRadioAnchorListBean resGetRadioAnchorListBean = JSON.parseObject(jsonRes, ResGetRadioAnchorListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetRadioAnchorListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetRadioAnchorListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetRadioAnchorListBean);
                    break;
                case NetConstant.GETRADIODATA:
                    ResGetRadioAnchorHomePageBean resGetRadioAnchorHomePageBean = JSON.parseObject(jsonRes, ResGetRadioAnchorHomePageBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetRadioAnchorHomePageBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetRadioAnchorHomePageBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetRadioAnchorHomePageBean);
                    break;
                case NetConstant.SYSLOGOUT:
                    ResBaseBean syslogout = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(syslogout.getExeustate().getState()));
                    mAsResult.setResultMsg(syslogout.getExeustate().getMsg());
                    break;
                case NetConstant.PUSHBINDINGFORAPPID:
                    ResBaseBean pushBindingForAppidBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(pushBindingForAppidBean.getExeustate().getState()));
                    mAsResult.setResultMsg(pushBindingForAppidBean.getExeustate().getMsg());
                    break;
                case NetConstant.GETMESSAGELIST:
                    ResGetMessageListBean resGetMessageListBean = JSON.parseObject(jsonRes, ResGetMessageListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetMessageListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetMessageListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetMessageListBean);
                    break;
                case NetConstant.GETHOMEWORKLIST:
                    ResGetHomeWorkListBean resGetHomeWorkListBean = JSON.parseObject(jsonRes, ResGetHomeWorkListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetHomeWorkListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetHomeWorkListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetHomeWorkListBean);
                    break;
                case NetConstant.GETRANKINGLIST:
                    ResGetRankingListBean resGetRankingListBean = JSON.parseObject(jsonRes, ResGetRankingListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetRankingListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetRankingListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetRankingListBean);
                    break;
                case NetConstant.GETHOMEWORKFANSFOLLOWLIST:
                    ResGetHomeWorkFansFollowListBean resGetHomeWorkFansFollowListBean = JSON.parseObject(jsonRes, ResGetHomeWorkFansFollowListBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resGetHomeWorkFansFollowListBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resGetHomeWorkFansFollowListBean.getExeustate().getMsg());
                    mAsResult.setObj(resGetHomeWorkFansFollowListBean);
                    break;
                case NetConstant.HOMEWORK_FOLLOW:
                    ResBaseBean homework_followBean = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(homework_followBean.getExeustate().getState()));
                    mAsResult.setResultMsg(homework_followBean.getExeustate().getMsg());
                    break;
                case NetConstant.HOMEWORK_ASSIGN:
                    ResHomeworkAssignBean resHomeworkAssignBean = JSON.parseObject(jsonRes, ResHomeworkAssignBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resHomeworkAssignBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resHomeworkAssignBean.getExeustate().getMsg());
                    mAsResult.setObj(resHomeworkAssignBean);
                    break;
                case NetConstant.APPSTARTUP:
                    ResAppStartUpBean resAppStartUpBean = JSON.parseObject(jsonRes, ResAppStartUpBean.class);
                    mAsResult.setResultCode(Integer.valueOf(resAppStartUpBean.getExeustate().getState()));
                    mAsResult.setResultMsg(resAppStartUpBean.getExeustate().getMsg());
                    mAsResult.setObj(resAppStartUpBean);
                    break;
                default:
                    ResBaseBean defaultRes = JSON.parseObject(jsonRes, ResBaseBean.class);
                    mAsResult.setResultCode(Integer.valueOf(defaultRes.getExeustate().getState()));
                    mAsResult.setResultMsg(defaultRes.getExeustate().getMsg());
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.e(TAG, "getNetJsonData :" + e.toString());
            mAsResult.setResultCode(NetConstant.MSG_CONNECT_OTHER_FAILED);
        }
        return mAsResult;
    }

    private String executeWebServiceReq(int businessType, Map<String, String> params) {
        String actionName = array.get(businessType);
        LogUtil.d(TAG, "正在请求接口：" + actionName);
        SoapObject request = new SoapObject(LocalConstant.NAMESPACE, actionName);
        String s = "";
        for (Map.Entry<String, String> entry : params.entrySet()) {
            request.addProperty(entry.getKey(), entry.getValue());
            LogUtil.d(TAG, entry.getKey() + ":" + entry.getValue());
            s += entry.getKey() + "=" + entry.getValue() + "&";
        }
        String substring = s.substring(0, s.length() - 1);
        LogUtil.d(TAG, LocalConstant.SERVER_URL + "/" + actionName + "?" + substring);
        return JsonHTTP.getobject(actionName, request);
    }

    private SparseArray<String> array;

    public static String dealDoubleQuotes(String str) {
        String dest = "";
        if (str != null) {
            Pattern p = Pattern.compile("\"");
            Matcher m = p.matcher(str);
            dest = m.replaceAll("");
        }
        return dest;
    }

}
